home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / psetting / pseval.exe / _SETUP.1 / Main.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1997-11-03  |  1.9 KB  |  88 lines

  1. unit Main;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   PSetting, Db, Grids, DBGrids, StdCtrls, ComCtrls, ExtCtrls, DBTables;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     fstMain: TPFormSettings;
  12.     tblPreferences: TTable;
  13.     dtsPreferences: TDataSource;
  14.     Label1: TLabel;
  15.     Panel1: TPanel;
  16.     Label2: TLabel;
  17.     CheckBox1: TCheckBox;
  18.     Edit1: TEdit;
  19.     UpDown1: TUpDown;
  20.     Memo1: TMemo;
  21.     Button1: TButton;
  22.     Button2: TButton;
  23.     Button3: TButton;
  24.     DBGrid1: TDBGrid;
  25.     tblPreferencesUserName: TStringField;
  26.     tblPreferencesPreferences: TBlobField;
  27.     procedure Button2Click(Sender: TObject);
  28.     procedure Button3Click(Sender: TObject);
  29.     procedure FormShow(Sender: TObject);
  30.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  31.   private
  32.     { Private declarations }
  33.   public
  34.     { Public declarations }
  35.   end;
  36.  
  37. var
  38.   Form1: TForm1;
  39.  
  40. implementation
  41.  
  42. {$R *.DFM}
  43.  
  44.  
  45. procedure TForm1.Button2Click(Sender: TObject);
  46. var
  47.     tempStream : TBlobStream;
  48. begin
  49.     tblPreferences.Edit;
  50.     tempStream := TBlobStream.Create( tblPreferencesPreferences, bmWrite );
  51.  
  52.     try
  53.         fstMain.SaveToStream( tempStream, '' );
  54.         tblPreferencesPreferences.Modified := TRUE;
  55.         tblPreferences.Post;
  56.     finally
  57.         tempStream.Free;
  58.     end;
  59. end;
  60.  
  61. procedure TForm1.Button3Click(Sender: TObject);
  62. var
  63.     tempStream : TBlobStream;
  64. begin
  65.     tblPreferences.Edit;
  66.     tempStream := TBlobStream.Create( tblPreferencesPreferences, bmReadWrite );
  67.  
  68.     try
  69.         fstMain.RestoreFromStream( tempStream );
  70.         tblPreferences.Cancel;
  71.     finally
  72.         tempStream.Free;
  73.     end;
  74. end;
  75.  
  76.  
  77. procedure TForm1.FormShow(Sender: TObject);
  78. begin
  79.     tblPreferences.Open;
  80. end;
  81.  
  82. procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
  83. begin
  84.     tblPreferences.Close;
  85. end;
  86.  
  87. end.
  88.